package com.contactsconverter.component;


import com.contactsconverter.utils.CTEventUtil;
import com.contactsconverter.utils.CTUtils;

import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.util.Log;


public class CTNetworkChangeReceiver extends BroadcastReceiver{

	Context context;
	@Override
	public void onReceive(final Context context, final Intent intent) {

		this.context = context;
		if(CTUtils.isConnected(context))
		{
			Log.d("Netowk Available ", "Flag No 1");

			String networkMode= CTUtils.getPreference(CTUtils.EVENT_NETWORK_MODE, context);

			Log.d("Netowk Available ", "Flag No 1"+networkMode);


			if(CTUtils.stringToInt(networkMode)>0)
			{
				CTEventUtil ctEventutil = new CTEventUtil(context);
				ctEventutil.onGetEvent();
				CTUtils.savePreference(CTUtils.EVENT_NETWORK_MODE, "0", context);
			}

			if(CTUtils.autoSynchroniseService == null){
				CTUtils.startParallalDemonContact(context);
				CTUtils.startSerialDemonContact(context);
			}
		}

	}





}
